package demo5;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardDemo {
    public static final String[] suits={"♠", "♥", "♣", "♦"};
    List<Card> deck = new ArrayList<>(52);
    public void createDeck(){
        for (int i = 0; i < suits.length; i++) {
            for (int j = 0; j < 13; j++) {
                Card card = new Card(j+1, suits[i]);
                deck.add(card);
            }
        }
    }

    public void swapCards(int i,int j){
        Card temp = deck.get(i);
        deck.set(i, deck.get(j));
        deck.set(j, temp);
    }
    public  void shuffleDeck(){
        Random random=new Random();
        int count = 1;
        for (int i = deck.size()-1; i >0 ;i--) {
            int j = random.nextInt(deck.size()-count);
            swapCards(i,j);
            count++;
        }
    }
}
